import User.AdminUserFactory;
import User.Factory;
import User.User;
import User.NormalUserFactory;
import User.ProxyUser;

import java.util.Scanner;

public class LibrarySystem {
    public static void main(String[] args) {
        Factory adminFactory = new AdminUserFactory();
        User zhangsan = adminFactory.creatUser(223,"zhangsan");

        Factory normalFactory = new NormalUserFactory();
        User lisi = normalFactory.creatUser(222,"lisi");
        User wangwu = normalFactory.creatUser(221,"wangwu");

        ProxyUser proxyAdminZ = new ProxyUser(zhangsan);
        ProxyUser proxyNormalL = new ProxyUser(lisi);
        ProxyUser proxyNormalW = new ProxyUser(wangwu);

        LibrarySystem librarySystem = new LibrarySystem();
        ProxyUser currentUser = librarySystem.selectProxyRole(proxyAdminZ, proxyNormalL, proxyNormalW);
        while(true) {
            int choice = currentUser.mune();
            currentUser.handleOperation(choice);
        }
    }
    public ProxyUser selectProxyRole(ProxyUser proxyAdminZ,ProxyUser proxyNormalL,ProxyUser proxyNormalW) {
        System.out.println("请选择角色登录：");
        System.out.println("1、管理员(zhangsan)\n2、普通用户(lisi)\n3、普通用户(wangwu)\n4、退出系统");
        ProxyUser currentUser = null;
        Scanner scanner = new Scanner(System.in);
        int choice = scanner.nextInt();
        switch (choice){
            case 1 :
                currentUser = proxyAdminZ;
                break;
            case 2:
                currentUser = proxyNormalL;
                break;
            case 3:
                currentUser = proxyNormalW;
                break;
            case 4:
                System.exit(0);
                break;
            default:
                break;
        }
        return currentUser;
    }
}
